#@Time:2021/6/7 20:36
#@Author:5120195554王欣霏
#-*- coding = utf-8 -*-

import os
import pygame
from scene.tiled_scene import TileScene as tilescene
from classes.base_operate import BaseOperate as baseoperate
from actor.swk import SWK
from classes.elder import Elder
from classes.sprite1 import Sprite1
from classes.sprite2 import Sprite2

pygame.init()
backtmxpath = os.path.join('../resource','tmx','village1.tmx')
# screen = pygame.display.set_mode((800,600),pygame.RESIZABLE) #主图层
# pygame.display.set_caption("扩展任务")
bo = baseoperate() #bo就是BaseOperate类的对象
screen = bo.screen

# tr = tiled.TiledRenderer(backtmxpath)#通过tiledrender的构造器构造出了tiledrender的对象
# backsurface = pygame.Surface(tr.pixel_size)#背景图层
# tr.render_map(backsurface)#渲染图层
# #这里才是真的将图层绘制出来了
# winsurface = backsurface.subsurface((300,300,800,600))#0,0表示没有偏移量

ts = tilescene(backtmxpath)
backsurface = ts.surface
winsurface = backsurface.subsurface((300,300,800,600))

swk_player = SWK()
elder = Elder()
sprite1 = Sprite1()
sprite2 = Sprite2()

#主图层
while True:
    # for event in pygame.event.get():
    #     if event.type == QUIT:
    #         exit()
    # screen.blit(winsurface,(0,0))
    # pygame.display.update()
    baseoperate.display(bo,winsurface,swk_player,elder,sprite1,sprite2) #将精灵以可变长形参传入